#include "Land.h"

Land::Land(D3DXVECTOR2 position,  EObjectType type) : GameObject(position, ELand)
{
	realType = type;
	switch(type)
	{
	case EL_Brick:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::Brick_ID),2,1,2,1,1);
		break;
	case EL_Block:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::Brick_ID),2,1,2,0,0);
		break;
	case EL_Land1:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::LAND1_ID),1,1,1,0,0);
		break;
	case EL_Land2:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::LAND2_ID),1,1,1,0,0);
		break;
	case EL_Land3:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::LAND3_ID),1,1,1,0,0);
		break;
	case EL_PiPe:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::PIPE_ID),1,1,1,0,0);
		break;
	case EL_BarUp:
	case EL_BarDown:
		m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::Bar_ID),1,1,1,0,0);
		break;
	}
}

Land::~Land()
{
	GameObject::~GameObject();
}

void Land::Update(float dt)
{
	if(realType == EL_BarUp)
	{
		m_velocity.y = BARSPEED*dt*60;
		m_position.y += m_velocity.y;
		if(m_position.y > 600)
			m_position.y = 0;
	}
	if(realType == EL_BarDown)
	{
		m_velocity.y = -BARSPEED*dt*60;
		m_position.y += m_velocity.y;
		if(m_position.y < 0)
			m_position.y = 600;
	}
}
